Solving Bayesian Inverse Problems Via Variational Autoencoders